/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.customer.core.repository.mapper;


import info.peigen.hotpot.business.customer.core.repository.entity.PartnerEntity;
import info.peigen.hotpot.business.customer.facade.enums.partner.PartnerStatus;
import info.peigen.hotpot.component.data.repository.beetlsql.mapper.AbstractBeetlSqlMapper;
import org.apache.ibatis.annotations.Mapper;
import org.beetl.sql.mapper.annotation.Select;
import org.beetl.sql.mapper.annotation.Sql;
import org.beetl.sql.mapper.annotation.Update;

import java.util.List;

/**
 * <b>(PartnerMapper)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/8/1
 */
@SuppressWarnings("AlibabaAbstractMethodOrInterfaceMethodMustUseJavadoc")
@Mapper
public interface PartnerMapper extends AbstractBeetlSqlMapper<PartnerEntity> {
    @Sql("select * from partner where partner_id = ?")
    @Select
    PartnerEntity findByPartnerId(String partnerId);

    @Sql("select * from partner where partner_name = ?")
    @Select
    PartnerEntity findByPartnerName(String partnerName);

    @Sql("select * from partner where status = ?")
    @Select
    List<PartnerEntity> listByStatus(PartnerStatus status);

    @Sql("select * from partner where memo = ?")
    @Select
    List<PartnerEntity> listByMemo(String memo);

    @Sql("delete from partner where partner_id = ?")
    @Update
    void deleteByPartnerId(String partnerId);

    @Sql("delete from partner where partner_name = ?")
    @Update
    void deleteByPartnerName(String partnerName);

    @Sql("select * from partner where partner_name like '%?%' or abbreviation like ?")
    @Select
    List<PartnerEntity> select(String partnerName, String partnerName2);

    @Sql("select * from partner where partner_id = ? for update")
    @Select
    PartnerEntity lockByPartnerId(String partnerId);
}